package org.sidora.strata.explorer;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.TopComponent;
import org.sidora.strata.Storage;


/**
 * Action which shows SectorExplorer component.
 * @author Enric Tartera, Juan Manuel Gimeno, Roger Masgoret
 * @version 1.0
 */
public class SectorExplorerAction extends AbstractAction {
    
    public SectorExplorerAction() {
        super(NbBundle.getMessage(SectorExplorerAction.class, "CTL_SectorExplorerAction"));
//        putValue(SMALL_ICON, new ImageIcon(Utilities.loadImage(SectorExplorerTopComponent.ICON_PATH, true)));
    }
    
    public void actionPerformed(ActionEvent evt) {
        TopComponent win = SectorExplorerTopComponent.findInstance();
        win.setDisplayName("Sector");
        win.open();
        win.requestActive();
    }
    
    public void fillSectorItems(){
        SectorExplorerTopComponent win = SectorExplorerTopComponent.findInstance();
        win.fillSectorItems();
        Storage.setSector(null);
        Storage.setFeature(null);
        Storage.setContext(null);
        Storage.getFeatureExplorerAction().fillFeatureItems();
        Storage.getContextExplorerAction().fillContextItems();
    }
    
    public void cerrar(){
        SectorExplorerTopComponent win = SectorExplorerTopComponent.findInstance();
        win.close();
    }
}
